package main

import (
	"fmt"
	"spider/common"
	"spider/fetcher"
	"spider/models"
	"spider/parse"
)

func main() {

	err := common.InitConfig("./conf.json")
	if nil != err {
		panic(err)
	}
	models.Connect()

	var header models.Header
	header = make(models.Header)

	header["Referer"] = "https://bj.meituan.com/meishi/"

	header = common.MergreHeader(header, common.CommonHeader)


	req := models.Request{
		Url:        "https://bj.meituan.com/meishi/",
		Header:     header,
		ReqFunc:    fetcher.FetchGet,
		Parser:     parse.ParseMeituanList,
		ParserName: "ParseMeituanList",
		DataFromParent:models.DataFromParent{"page":1,"cate":""},
	}

	res,err:=req.ReqFunc(req.Url,req.Header,"");
	if err!=nil{
		panic(err)
	}
	pareRes,err:=req.Parser(res,req.DataFromParent)
	if err!=nil{
		panic(err)
	}
	for _,v:=range pareRes.Requests{
		fmt.Printf("%+v\n",v)

	}






}
